
#ifndef __DOCUMENT_H__
#define __DOCUMENT_H__

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <gtksourceview/gtksourcelanguagemanager.h>
#include <gtksourceview/gtksourceview.h>
#include <stdlib.h>
#include <string.h>
#include <gdk/gdk.h>
#include "goto_line_panel.h"
#include "search_panel.h"
#include "replace_panel.h"

G_BEGIN_DECLS


#define TYPE_DOCUMENT (document_get_type ())
#define DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_DOCUMENT, Document))
#define DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_DOCUMENT, DocumentClass))
#define IS_DOCUMENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_DOCUMENT))
#define IS_DOCUMENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_DOCUMENT))
#define DOCUMENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_DOCUMENT, DocumentClass))

typedef struct _Document Document;
typedef struct _DocumentClass DocumentClass;
typedef struct _DocumentPrivate DocumentPrivate;

#define DOCUMENT_TYPE_DOCUMENT_STATE (document_document_state_get_type ())

struct _Document {
	GtkVBox parent_instance;
	DocumentPrivate * priv;
	GtkSourceLanguage* source_lang;
	GtkSourceBuffer* source_buff;
	GtkSourceView* source_view;
	GoToLinePanel* goto_line_panel;
	SearchPanel* search_panel;
	ReplacePanel* replace_panel;
};

struct _DocumentClass {
	GtkVBoxClass parent_class;
	gboolean (*on_focus_in_event) (Document* self, GtkSourceView* source_view, const GdkEventFocus* event);
	gboolean (*on_show_doc_panel) (Document* self);
	gboolean (*on_hide_doc_panel) (Document* self);
};

typedef enum  {
	DOCUMENT_DOCUMENT_STATE_NO_MODIFIED,
	DOCUMENT_DOCUMENT_STATE_MODIFIED,
	DOCUMENT_DOCUMENT_STATE_READ_ONLY
} DocumentDocumentState;


GType document_document_state_get_type (void);
extern GtkSourceLanguageManager* document_source_lang_manager;
void document_set_contents_from_file (Document* self, const char* file_path);
char* document_get_content (Document* self);
void document_on_modified_changed (Document* self);
void document_search_sensitive_update (Document* self);
void document_insert_text_at_cursor (Document* self, const char* text);
Document* document_construct (GType object_type, const char* file_path);
Document* document_new (const char* file_path);
gboolean document_save (Document* self);
gboolean document_save_as (Document* self);
gboolean document_close (Document* self);
inline void document_undo (Document* self);
inline void document_redo (Document* self);
inline void document_cut (Document* self);
inline void document_copy (Document* self);
inline void document_paste (Document* self);
inline void document_delete_selection (Document* self);
inline void document_select_all (Document* self);
inline void document_grab_focus (Document* self);
void document_show_search_panel (Document* self);
void document_show_replace_panel (Document* self);
void document_goto_next_found_match (Document* self);
void document_goto_prev_found_match (Document* self);
void document_show_goto_line_panel (Document* self);
gboolean document_on_focus_in_event (Document* self, GtkSourceView* source_view, const GdkEventFocus* event);
gboolean document_on_show_doc_panel (Document* self);
gboolean document_on_hide_doc_panel (Document* self);
DocumentDocumentState document_get_state (Document* self);
GType document_get_type (void);


G_END_DECLS

#endif
